﻿using System;
using System.Collections.Generic;
 
using System.Text;
using GGSharp.Structures;

namespace GGSharp.Packets
{
    /// <summary>
    /// Pakiet zawierajacy czesc lub calosc importowanej listy kontaktow
    /// </summary>
    public class PubDirRequest50Packet : HeaderPacket
    {
        private byte _type = 0x02;
        private int _seq = (int)DateTime.Now.Ticks;
        private PubDirContactBase _query;

        public PubDirRequest50Packet()
        {
            this.Type = PacketType.GG_PUBDIR50_REQUEST;
            this.Length = 5;
        }

        public PubDirContactBase Query
        {
            get { return _query; }
            set { _query = value; }
        }

        public PubDirType QueryType
        {
            get { return (PubDirType)_type; }
            set { _type = (byte)value; }
        }

        public int Sequence
        {
            get { return _seq; }
        }

        public override void Write(System.IO.BinaryWriter writer)
        {
            if (_query != null)
                this.Length += _query.Length;

            base.Write(writer);

            writer.Write(_type);
            writer.Write(_seq);

            if (_query != null)
                _query.Write(writer);
        }
    }
}
